//
//  Hen_ConfigDefine.h
//  Peccancy
//
//  Created by mini2 on 16/11/15.
//  Copyright © 2016年 Peccancy. All rights reserved.
//
// 配置定义
//

#ifndef Hen_ConfigDefine_h
#define Hen_ConfigDefine_h

#pragma mark -- 服务器地址
#define APP_SERVER                      @""
#define SERVER_TEST                     @"http://app.sdksmr.com"
#define FILEUPLOAD_SERVER               @""
#define Img_SERVER                      @"http://app.sdksmr.com"


// 日志打印
#ifdef DEBUG

#define NSLog(FORMAT, ...) {\
NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];\
[dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];\
NSString *str = [dateFormatter stringFromDate:[NSDate date]];\
printf("%s %s [第%d行]\n method: %s \n %s\n",[str UTF8String], [[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, __PRETTY_FUNCTION__, [[NSString stringWithFormat:(FORMAT), ##__VA_ARGS__] UTF8String]);\
}
#else
#define NSLog(...)
#endif

/******************************** 尺寸相关 ***************************************/

// 状态栏的高度
#define STATUSBARHEIGHT [[UIApplication sharedApplication] statusBarFrame].size.height

// 导航条高度
#define NAVBARHEIGHT 44.f

// 导航栏高度
#define TOPBARHEIGHT (STATUSBARHEIGHT + NAVBARHEIGHT)

// iphoneX-SafeArea的高度
#define SAFEAREAHEIGHT ([[UIApplication sharedApplication] statusBarFrame].size.height>20 ? 34 : 0)

#define kMainScreenScale ([UIScreen mainScreen].scale)


/******************************** Utils ***************************************/

// token
#define User_Token [kUserDefaults objectForKey:@"token"]
// 七牛token
#define QNToken  [kUserDefaults objectForKey:@"QNToken"]
// 融云token
#define RC_Token  [kUserDefaults objectForKey:@"RCToken"]

// 获取主窗体
#define KAppWindow [UIApplication sharedApplication].keyWindow
#define kAppDelegate [UIApplication sharedApplication].delegate

//强弱引用
#define WEAKSELF __weak typeof(self) weakSelf = self;
#define kWeakSelf(type) __weak typeof(type)weak##type = type;
#define kStrongSelf(type) __strong typeof(type)type = weak##type;

//GCD - 一次性执行
#define kDISPATCH_ONCE_BLOCK(onceBlock) static dispatch_once_t onceToken; dispatch_once(&onceToken, onceBlock);
//GCD - 在主线程上运行
#define kDISPATCH_MAIN_THREAD(mainQueueBlock) dispatch_async(dispatch_get_main_queue(), mainQueueBlock);
//GCD - 开启异步线程
#define kDISPATCH_GLOBAL_QUEUE_DEFAULT(globalQueueBlock) dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), globalQueueBlock);
//GCD - 延迟执行
#define KDISPATCH_DELAY(time, delayQueueBlock) dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(time * NSEC_PER_SEC)), dispatch_get_main_queue(), delayQueueBlock);

// NSUserDefaults
#define kUserDefaults [NSUserDefaults standardUserDefaults]
// NSNotificationCenter
#define kNotificationCenter [NSNotificationCenter defaultCenter]

// 设置通用字体
#define WSFontMake(s)       [UIFont fontWithName:@"PingFangSC-Medium" size:s]
#define WSBoldFontMake(s)   [UIFont fontWithName:@"PingFangSC-Bold" size:s]

#define WSImageMake(imgName) [[UIImage imageNamed:imgName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal]

// 默认占位图片
#define kPlaceHolderImage [UIImage imageNamed:@"img_yyzz"]

// 判断字符串是否为空
#define STR_Is_NullOrEmpty(str) (str == nil || [str isEqualToString:@""])

/******************************** 颜色相关 ***************************************/

#define COLOR_HEX(rgb) ([UIColor colorWithRed:((float)((rgb & 0xFF0000) >> 16))/255.0 green:((float)((rgb & 0xFF00) >> 8))/255.0 blue:((float)(rgb & 0xFF))/255.0 alpha:1.0])

///字体黑色
#define kFontColorBlack         [UIColor colorWithHexString:@"#333333"]
///字体灰色
#define kFontColorGray          [UIColor colorWithHexString:@"#999999"]
///字体橙色
#define kFontColorOrange        [UIColor colorWithHexString:@"#F0302F"]
///字体白色
#define kFontColorWhite         [UIColor colorWithHexString:@"#ffffff"]
///字体绿色
#define kFontColorGreen         [UIColor colorWithHexString:@"#01CAAF"]

#define kFontColorRed           [UIColor colorWithHexString:@"#ff5b5b"]

///主题颜色 绿色
#define kThemeGreenColor        [UIColor colorWithHexString:@"#00C9AE"]
///通用背景颜色
#define kCommonWhiteBg          [UIColor colorWithHexString:@"#ffffff"]
#define kCommonBackgroudColor   [UIColor colorWithHexString:@"#f5f5f5"]

/// 分割线颜色
#define kSeparatorColor         [UIColor colorWithHexString:@"#DFDFDF"]



#define  adjustsScrollViewInsets_NO(scrollView,vc)\
do { \
_Pragma("clang diagnostic push") \
_Pragma("clang diagnostic ignored \"-Warc-performSelector-leaks\"") \
if ([UIScrollView instancesRespondToSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:")]) {\
[scrollView   performSelector:NSSelectorFromString(@"setContentInsetAdjustmentBehavior:") withObject:@(2)];\
} else {\
vc.automaticallyAdjustsScrollViewInsets = NO;\
}\
_Pragma("clang diagnostic pop") \
} while (0)

/******************************** 第三方appkey，appsecret ***************************************/

///新浪微博
#define SINA_APP_KEY @"333900906"
#define SINA_APP_SECRET @"0fe03f996c725f91d778080f8c38b346"
///QQ
#define QQ_APP_KEY @"1105731141"
#define QQ_APP_SECRET @"2mBDWLfXsfI7gcZp"
///友盟
#define UM_APPKey @"589adc26cae7e732bf000bad"
///微信
#define WX_BASE_URL @"https://api.weixin.qq.com/sns"
#define WX_APP_KEY @"wxa242646122b08a35"
#define WX_APP_SECRET @"4a8fa70cd1ab41b08024eb962142b4a0"
///微信支付
#define WX_PAY_APP_KEY  @"wxa242646122b08a35"
#define WX_DESCRIPTION  @"ask"
#define AMAP_KEY    @"8227c13836e835202ddf701c838b4fec"


#endif /* Hen_ConfigDefine_h */
